/**
 * 问题列表
 */
import query from '../../untils/mysql';
import { Tip } from '../../untils/untils';
import { check, validationResult } from 'express-validator';

const validator = [
    check('problemId').notEmpty().withMessage("问题Id不能为空！")
]

const GET = async (req: any, res: any, next: any) => {
    try {
        var errors = validationResult(req);
        if (!errors.isEmpty()) {
            return Tip.tipError(res, errors.array()[0].msg);
        }
        const { problemId } = req.query;
        const data = await query(`select * from problem_move where problemId = '${problemId}'`);
        return Tip.tipSuccess(res, '查询成功', data)
    } catch (error: any) {
        Tip.tipError500(res, error)
    }
}

export {
    GET,
    validator
}